<template>
    <div>
        <header class="pr white" style="padding: 45px 0px 40px;">
            <img src="../../assets/images/7.jpg" class="displayB centerauto shadowB" style="max-width: 70%;margin: 0px auto;padding: 10px;background: #fff;" />
        </header>
        <van-cell-group>
            <van-cell-group>
                <van-radio-group v-model="isType">
                    <div class="van-cell flexbox spacebetween">
                        <p style="width: 70px;">
                            提现到：
                        </p>
                        <div class="clearfix text-center" style="width: calc(100% - 70px);">
                            <!-- <van-radio name="1" style="width: 50%;float:left;" checked-color="#d92626" >支付宝</van-radio> -->
                            <van-radio name="2" style="width: 50%;float:left;" checked-color="#d92626" >银行卡</van-radio>
                        </div>
                    </div>
                </van-radio-group>
            </van-cell-group>
            <van-field v-model="money" type="number" label="提现金额 $：" placeholder="请输入" />
            <span class="padding_lr15 font_12 maincolor">注：提现手续费为 {{harge}}%；提现时间约为1~3个工作日。</span>
            <van-field v-model="message" label="备注：" type="textarea" placeholder="" rows="3" autosize/>
            <van-field label="支付密码：" type="password" maxlength="6" v-model="password" placeholder="请输入支付密码" />
        </van-cell-group>
        <div class="text-center margin_t50">
            <van-button type="primary" class="width_80p btn_size_40" @click="submit">确 认</van-button>
        </div>
    </div>
</template>
<script>

    import '@/assets/css/main.css'
    export default {
        data(){
            return{
                isType: '2',
                money: '',
                message: '',
                password: '',
                harge: '',
            }
        },
        methods: {
            init(){
                
                this.harge = this.$route.query.harge;
            },
            //提交
            submit(){
                var _this = this;

                if(!this.money){
                    this.$toast('请输入提现金额');
                    return;
                }else{

                    // if(parseFloat(this.money)%100 != 0){
                    //     this.$toast('提现金额需是100的倍数');
                    //     return;
                    // }
                    if(parseFloat(this.money) < 20){
                        this.$toast('提现金额不能少于20美金');
                        return;
                    }
                }
                if(!this.message){
                    this.$toast('请输入提现备注');
                    return;
                }
                if(!this.password){
                    this.$toast('请输入支付密码');
                    return;
                }

                this.$httpPost('/api/index/Personal_center/userWithdrawal',{
                    'u_id': window.localStorage.u_id,
                    'type': this.isType,
                    'money': this.money,
                    'remark': this.message,
                    'password': this.password,
                }).then(response => {
                    
                    if(response.code == 200){

                        _this.$toast(response.msg);

                        setTimeout(() => {
                            _this.$router.push({
                                path: '/cashrecord',
                            });
                        }, 2000);
                    }else{
                        
                        _this.$toast(response.msg);
                    }

                });
            },
        },
        mounted(){
            this.init();
        },
    }
</script>